﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Travel.Web.route_image
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					Guid id=new Guid(Request.Params["id"]);
					ShowInfo(id);
				}
			}
		}
			
	private void ShowInfo(Guid id)
	{
		Travel.BLL.route_image bll=new Travel.BLL.route_image();
		Travel.Model.route_image model=bll.GetModel(id);
		this.lblid.Text=model.id.ToString();
		this.txtroute_id.Text=model.route_id.ToString();
		this.txtname.Text=model.name;
		this.txtserial_no.Text=model.serial_no.ToString();
		this.txturl.Text=model.url;
		this.txtcreated_on.Text=model.created_on.ToString();
		this.txtcreated_by.Text=model.created_by;
		this.txtchanged_on.Text=model.changed_on.ToString();
		this.txtchanged_by.Text=model.changed_by;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtroute_id.Text))
			{
				strErr+="route_id格式错误！\\n";	
			}
			if(this.txtname.Text.Trim().Length==0)
			{
				strErr+="图片名称不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtserial_no.Text))
			{
				strErr+="序号格式错误！\\n";	
			}
			if(this.txturl.Text.Trim().Length==0)
			{
				strErr+="地址不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtcreated_on.Text))
			{
				strErr+="创建时间格式错误！\\n";	
			}
			if(this.txtcreated_by.Text.Trim().Length==0)
			{
				strErr+="创建人不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtchanged_on.Text))
			{
				strErr+="最后修改时间格式错误！\\n";	
			}
			if(this.txtchanged_by.Text.Trim().Length==0)
			{
				strErr+="最后修改人不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			Guid id= new Guid(this.lblid.Text);
			int route_id=int.Parse(this.txtroute_id.Text);
			string name=this.txtname.Text;
			int serial_no=int.Parse(this.txtserial_no.Text);
			string url=this.txturl.Text;
			DateTime created_on=DateTime.Parse(this.txtcreated_on.Text);
			string created_by=this.txtcreated_by.Text;
			DateTime changed_on=DateTime.Parse(this.txtchanged_on.Text);
			string changed_by=this.txtchanged_by.Text;


			Travel.Model.route_image model=new Travel.Model.route_image();
			model.id=id;
			model.route_id=route_id;
			model.name=name;
			model.serial_no=serial_no;
			model.url=url;
			model.created_on=created_on;
			model.created_by=created_by;
			model.changed_on=changed_on;
			model.changed_by=changed_by;

			Travel.BLL.route_image bll=new Travel.BLL.route_image();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
